package gate

import io.netty.channel.{ChannelHandlerContext, ChannelInboundHandlerAdapter}

/**
  * Created by Xavier on 2017/9/12.
  */
class GateServerHandler extends ChannelInboundHandlerAdapter{

    override def channelRead(ctx: ChannelHandlerContext, msg: scala.Any): Unit = {
        println("GateServerHandler read msg, address: ", ctx.channel().remoteAddress()," msg: ", msg.toString)
        ctx.write("GateServerHandler write :" + msg)
        ctx.flush()
    }

    override def exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable): Unit = {
        super.exceptionCaught(ctx, cause)
        cause.printStackTrace()
        ctx.close()
    }

}
